// Term.cpp: implementation of the Term class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Expression.h"
#include "Term.h"
#include "Factor.h"
#include "Mulop.h"
#include "_Term.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Term::Term()
{
}

Term::~Term()
{
	delete m_pOperatorNote;
}

BOOL Term::Interpret()
{
	_Term* pTerm = NULL;
	return DualityOperIterpret<Factor, Term, _Term>(pTerm, this, 2, CString(_T("*")), CString(_T("/")));
/*	ComplierNote* pNote = new Factor;
	pNote->SetOwner(this);
	LeftNote(pNote);
	if(!pNote->Interpret())
		return FALSE;

	CString strTemp;
	strTemp = AAnalyzer()->GetCurSymbol();
	if(strTemp == _T("*") || strTemp == _T("/"))
	{
		m_pOperatorNote = new Mulop;
		m_pOperatorNote->SetOwner(this);
		if(!m_pOperatorNote->Interpret())
			return FALSE;

		pNote = new Term;
		pNote->SetOwner(this);
		RightNote(pNote);
		return pNote->Interpret();
	}
	
	return TRUE;*/
}

Variable Term::Execute()
{
	if(m_pOperatorNote != NULL)
	{
		return m_pOperatorNote->Execute();
	}
	else
	{
		return LeftNote()->Execute();
	}
}